package com.cloudoer.blog.base;

import com.cloudoer.blog.service.*;
import com.cloudoer.blog.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public abstract class BaseController {
    protected final String SUCCESS = "success";
    protected final String ERROR = "error";

    @Autowired
    protected AlbumService albumService;
    @Autowired
    protected ArticleService articleService;
    @Autowired
    protected CommentService commentService;
    @Autowired
    protected FiledService filedService;
    @Autowired
    protected FiletypeService filetypeService;
    @Autowired
    protected MemberService memberService;
    @Autowired
    protected PhotoService photoService;
    @Autowired
    protected TagService tagService;
    @Autowired
    protected FileUtil fileUtil;


    protected Map<String, Object> result (String state, String message){
        Map<String, Object> map = new HashMap<>();
        map.put("state", state);
        map.put("message", message);
        return map;
    }

    protected Map<String, Object> result (Collection collection, int count, String msg){
        Map<String, Object> map = new HashMap<>();
        map.put("data", collection);
        map.put("code",0);
        map.put("msg",msg);
        map.put("count", count);
        return map;
    }
}
